﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.SqlServer.Dts.Runtime;

namespace SSISForSAPComponents
{
    public partial class ExportStructureEdit : Form
    {
        Microsoft.SqlServer.Dts.Runtime.Variables _variables;
        System.Data.DataTable _table;

        public ExportStructureEdit()
        {
            InitializeComponent();
            
        }
        public ExportStructureEdit(System.Data.DataTable table, Microsoft.SqlServer.Dts.Runtime.Variables variables)
            : this()
        {
            _table = table;
            _variables = variables; 
        }
        private void ExportStructureEdit_Load(object sender, EventArgs e)
        {
            try
            {
                this.dataGridView1.DataError += new DataGridViewDataErrorEventHandler(dataGridView1_DataError);
                if (_variables != null)
                {

                    foreach (Variable variable in _variables)
                    {
                        this.ExportVariable.Items.Add("@" + variable.Name);
                    }
                }

                this.dataGridView1.DataSource = _table;

            }
            catch (Exception ex)
            {
                
                throw ex;
            }
        }

        void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
            
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            _table.AcceptChanges();
            this.Close(); 
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            _table.RejectChanges();
            this.Close(); 
        }
       
    }
}
